package com.lx.gulimall.seckill.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
import org.springframework.session.web.http.CookieSerializer;
import org.springframework.session.web.http.DefaultCookieSerializer;

/**
 * @author lixun Email:lx3027@126.com
 * @create 2021-08-12 10:31
 */
@EnableRedisHttpSession
@Configuration
public class GulimallSessionConfig {
    /**
     * cookie序列化
     * @return
     */
    @Bean
    public CookieSerializer cookieSerializer(){
        DefaultCookieSerializer cookieSerializer = new DefaultCookieSerializer();
        // 领域范围
        cookieSerializer.setDomainName("gulimall.com");
        // cookie名字
        cookieSerializer.setCookieName("GULISESSION");
        return cookieSerializer;
    }

    /**
     * json
     * @return
     */
    @Bean
    public RedisSerializer<Object> springSessionDefaultRedisSerializer(){
        return new GenericJackson2JsonRedisSerializer();
    }

}
